<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/2/1 0001
 * Time: 18:06
 */

namespace app\admin\controller;


use app\admin\model\Feedback;
use think\Controller;

class AdminFeedback extends Controller
{
    //中间件登录限制
    protected $middleware = [
        'AdminCheck'
    ];
    //反馈列表
    public function feedback_list(){
        $feedback=new Feedback();
        $feedback=$feedback->order('update_time','desc')->paginate(10);
        $this->assign('feedbacks',$feedback);
        return $this->fetch();
    }
    //反馈回复
    public function feedback_return(){
        $data=input('post.');
        $feedback=new Feedback();
        $feedback=$feedback->save(
            [
                'return'=>$data['return']
            ],[
                'id'=>$data['id']
            ]
        );
        if ($feedback){
            $msg=$this->msg(200,'反馈成功');
        }else{
            $msg=$this->msg(400,'反馈失败');
        }
        return $msg;
    }
    //信息
    private function msg($statu,$msg){
        return[
            'statu' =>$statu,
            'msg'   =>$msg
        ];
    }
}